import axios from 'axios'


export const MediaTypeJSON = 'application/json'
export const MediaTypeFormData = 'multipart/form-data'
export const MediaTypeFormURLEncoded = 'application/x-www-form-urlencoded'
export const genContentType = (value: string) => ({ 'Content-Type': value })



function createInstance(baseURL: string) {
  const TIMEOUT = 1000 * 60

  const instance = axios.create({
    baseURL,
    timeout: TIMEOUT,
    headers: genContentType(MediaTypeJSON),
  })

  instance.interceptors.request.use(
    (config) => {
      return config
    },
    (error) => {
      return Promise.reject(error)
    },
  )

  instance.interceptors.response.use(
    (response) => {
      return response
    },
    (error) => {
      return Promise.reject(error)
    },
  )

  return instance
}

const business = createInstance('/iscas-gateway')
export const get = business.get
export const post = business.post

